package com.jstyle.beatecg.daoManager;


import com.jstyle.beatecg.dao.DbManager;
import com.jstyle.beatecg.dao.HrvDataDao;
import com.jstyle.beatecg.dao.PathRecordDao;
import com.jstyle.beatecg.dao.UserInfoDao;
import com.jstyle.beatecg.model.HrvData;
import com.jstyle.beatecg.model.PathRecord;
import com.jstyle.beatecg.model.UserInfo;

import org.greenrobot.greendao.query.QueryBuilder;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/10.
 */

public class PathRecordDaoManager {


    public static void insertPathRecord(PathRecord pathRecord){
        DbManager.getInstance().getDaoSession().getPathRecordDao().insert(pathRecord);
    }
    public static PathRecord getPathRecord(Long id){
        PathRecordDao pathRecordDao=DbManager.getInstance().getDaoSession().getPathRecordDao();
        QueryBuilder<PathRecord> builder = pathRecordDao.queryBuilder();
        builder.where(PathRecordDao.Properties.MId.eq(id));
        return builder.unique();
    }
    public static List<PathRecord> getPathRecord(String startDate, String endDate){
        List<PathRecord> hrvDataList=new ArrayList<>();
        QueryBuilder<PathRecord> queryBuilder= DbManager.getInstance().getDaoSession().getPathRecordDao().queryBuilder();
        hrvDataList= queryBuilder.where(PathRecordDao.Properties.MDate.between(startDate+" 00:00:00",endDate+" 23:59:00")).orderAsc(PathRecordDao.Properties.MDate).list();
        return hrvDataList;
    }


    public static void Deletehos(Long key){
        DbManager.getInstance().getDaoSession().getPathRecordDao().deleteByKey(key);
    }


    public static List<PathRecord> getAllPathRecord(){
        PathRecordDao pathRecordDao=DbManager.getInstance().getDaoSession().getPathRecordDao();
        QueryBuilder<PathRecord> builder = pathRecordDao.queryBuilder().orderDesc(PathRecordDao.Properties.MDate);
        return builder.list();
    }

}
